From: Simon McVittie Date: Sat, 17 Sep 2022 20:38:37 +0000 (+0100) Subject: Add proposed patch to fix keyboard shortcuts with X11 backend X-Git-Tag: archive/raspbian/4.8.3+ds-2+rpi1~3^2~54 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=2139a8c4eb0eadf4ce527cb6936a0d763970ad2e;p=gtk4.git Add proposed patch to fix keyboard shortcuts with X11 backend Closes: #1016927 --- diff --git a/debian/patches/build-Add-an-option-to-use-more-conservative-GResource-em.patch b/debian/patches/build-Add-an-option-to-use-more-conservative-GResource-em.patch index 311aca8f03..c1c067fa74 100644 --- a/debian/patches/build-Add-an-option-to-use-more-conservative-GResource-em.patch +++ b/debian/patches/build-Add-an-option-to-use-more-conservative-GResource-em.patch @@ -21,10 +21,10 @@ Signed-off-by: Simon McVittie 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gtk/meson.build b/gtk/meson.build -index 2e404f2..46f886f 100644 +index 080bffe..12e4ad7 100644 --- a/gtk/meson.build +++ b/gtk/meson.build -@@ -866,15 +866,28 @@ if not fs.exists('theme/Default/Default-light.css') +@@ -869,15 +869,28 @@ if not fs.exists('theme/Default/Default-light.css') endif @@ -55,7 +55,7 @@ index 2e404f2..46f886f 100644 # Create the resource blob diff --git a/meson_options.txt b/meson_options.txt -index 2084ab8..078e76f 100644 +index c1df747..fe779aa 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -78,6 +78,11 @@ option('f16c', diff --git a/debian/patches/gdkevents-Don-t-ignore-modifiers-that-are-not-currently-a.patch b/debian/patches/gdkevents-Don-t-ignore-modifiers-that-are-not-currently-a.patch new file mode 100644 index 0000000000..3f4f0bf673 --- /dev/null +++ b/debian/patches/gdkevents-Don-t-ignore-modifiers-that-are-not-currently-a.patch @@ -0,0 +1,81 @@ +From: Simon McVittie +Date: Sat, 17 Sep 2022 18:53:00 +0100 +Subject: gdkevents: Don't ignore modifiers that are not currently active + +The X11 backend can mark modifiers like Shift as consumed even if they +aren't actually active, which seems to be something to do with making +shortcuts like `plus` and `plus` work as +intended regardless of whether the plus symbol is obtained by pressing +Shift and a key (like `+/=` on American, British or French keyboards) +or not (like `*/+` on German keyboards). + +However, this can go badly wrong when the modifier is *not* pressed. +For example, terminals normally have separate bindings for `c` +(send SIGINT) and `c` (copy). If we disregard the +consumed modifiers completely, when the X11 backend marks Shift as +consumed, pressing Ctrl+c would send SIGINT *and* copy to the clipboard, +which is not what was intended. + +By masking out the members of `consumed` that are not in `state`, we +get the same interpretation for X11 and Wayland, and ensure that +keyboard shortcuts that explicitly mention Shift can only be triggered +while holding Shift. It continues to be possible to trigger keyboard +shortcuts that do not explicitly mention Shift (such as `plus`) +while holding Shift, if the backend reports Shift as having been +consumed in order to generate the plus keysym. + +Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/5095 +Bug-Debian: https://bugs.debian.org/1016927 +Signed-off-by: Simon McVittie +Forwarded: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5037 +--- + gdk/gdkevents.c | 22 +++++++++++++++++++--- + 1 file changed, 19 insertions(+), 3 deletions(-) + +diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c +index 4b61715..0daf475 100644 +--- a/gdk/gdkevents.c ++++ b/gdk/gdkevents.c +@@ -1773,7 +1773,7 @@ gdk_key_event_matches (GdkEvent *event, + guint ev_keyval; + int layout; + int level; +- GdkModifierType consumed_modifiers; ++ GdkModifierType ignored_modifiers; + GdkModifierType shift_group_mask; + gboolean group_mod_is_accel_mod = FALSE; + const GdkModifierType mask = GDK_CONTROL_MASK | +@@ -1792,7 +1792,23 @@ gdk_key_event_matches (GdkEvent *event, + ev_keyval = self->translated[1].keyval; + layout = self->translated[1].layout; + level = self->translated[1].level; +- consumed_modifiers = self->translated[1].consumed; ++ ++ /* ++ * If a modifier is currently active (e.g. Shift is pressed) and was marked ++ * as consumed, we ignore it for the purposes of matching shortcuts. ++ * For example, when Ctrl+Shift+[plus/equals key] is translated into ++ * Ctrl+plus on a keyboard where Shift+equals is the plus sign, we want ++ * shortcuts for either plus or plus to match. ++ * (See https://bugzilla.gnome.org/show_bug.cgi?id=100439) ++ * ++ * If a modifier is *not* currently active, the X11 backend can sometimes ++ * mark it as consumed where the Wayland and Windows backends do not. ++ * In this case, we still want to pay attention to its state. ++ * For example, when Ctrl+x is translated into Ctrl+x, we only want to ++ * trigger shortcuts for x, not for x. ++ * (See https://gitlab.gnome.org/GNOME/gtk/-/issues/5095) ++ */ ++ ignored_modifiers = (self->translated[1].consumed & state); + + /* if the group-toggling modifier is part of the default accel mod + * mask, and it is active, disable it for matching +@@ -1804,7 +1820,7 @@ gdk_key_event_matches (GdkEvent *event, + if (mask & shift_group_mask) + group_mod_is_accel_mod = TRUE; + +- if ((modifiers & ~consumed_modifiers & mask) == (state & ~consumed_modifiers & mask)) ++ if ((modifiers & ~ignored_modifiers & mask) == (state & ~ignored_modifiers & mask)) + { + /* modifier match */ + GdkKeymapKey *keys; diff --git a/debian/patches/series b/debian/patches/series index 2fcc607bea..a0d37e4e53 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,4 @@ +gdkevents-Don-t-ignore-modifiers-that-are-not-currently-a.patch build-Add-an-option-to-use-more-conservative-GResource-em.patch reftest_compare_surfaces-Report-how-much-the-images-diffe.patch reftests-Allow-minor-differences-to-be-tolerated.patch